// 存储token
function setToken(val){
	uni.setStorageSync('token',val);
}
 // 取出缓存token
function getToken(){
	let value = uni.getStorageSync('token');
	if(value === '' || value === undefined){
		return ''
	}
	return value;
}
// 删除缓存token
function removeToken(){
	uni.removeStorageSync('token');
}

// 存储个人信息
function setStrongUser(val){
	uni.setStorageSync('userInfo',JSON.stringify(val))
}
// 取出个人信息
function getStrongUser(){
	let user = uni.getStorageSync('userInfo');
	if(user === '' || user === undefined){
		return {};
	}
	return JSON.parse(user);
}
// 删除缓存token
function removeStrongUser(){
	uni.removeStorageSync('userInfo');
}
// 判断是否手机号码
function isPhone(phones){
    var myreg = /^[1][3,4,5,7,8,9][0-9]{9}$/;
    if (!myreg.test(phones)) {
      return false;
    } else {
      return true;
    }
}

function getYMDHMS (timestamp) {
	console.log(timestamp)
      let time = new Date(timestamp)
	  console.log(time)
      let year = time.getFullYear()
	  console.log(year)
      const month = (time.getMonth() + 1).toString().padStart(2, '0')
      const date = (time.getDate()).toString().padStart(2, '0')
      const hours = (time.getHours()).toString().padStart(2, '0')
      const minute = (time.getMinutes()).toString().padStart(2, '0')
      const second = (time.getSeconds()).toString().padStart(2, '0')

      return year + '-' + month + '-' + date + ' ' + hours + ':' + minute + ':' + second
    }

export default{
	setToken,
	getToken,
	removeToken,
	isPhone,
	setStrongUser,
	getStrongUser,
	removeStrongUser,
	getYMDHMS,
}